﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WmsReceiveOrderReset.aspx.cs" Inherits="JYH.Web.MES.WMS.UI.WmsReceiveOrderReset" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script type="text/javascript">
        $(function () {
            const urlParams = new URLSearchParams(window.location.search);
            const ReceiveOrderID = urlParams.get('ReceiveOrderID');
            $("#hReceiveOrderID").val(ReceiveOrderID);
            LoadReceiveItem($("#hReceiveOrderID").val());
            SelectRow("XX");
        });


        function LoadReceiveItem(ReceiveOrderID)
        {
            $('#OrderItem').datagrid({
                pageSize: 20,
                loadMsg: "正在接收数据...",
                method: 'Get',
                iconCls: 'icon-reload',
                url: '/api/WMS/QueryReciveOrderItem',
                queryParams: {
                    ReciveOrderID: ReceiveOrderID,
                    MaterialNO: "",
                    sort: "",
                    order: ""
                },
                height: document.documentElement.clientHeight - 100,
                idField: 'ReciveItemID',
                striped: true,      //隔行变色
                singleSelect: true, //是否单选
                pagination: true,   //分页控件  
                scrollbarSize: 0,
                fitColumns: true,
                columns: [[
                    {
                        field: 'ReciveItemID', // 复选框字段
                        checkbox: true // 表示这是一个复选框列
                    },
                    { field: 'ReciveOrderNO', title: '收料单号', width: 150 },
                    { field: 'ERPItem', title: 'ERP项次', width: 80, sortable: true },
                    { field: 'MaterialNO', title: '物料编号', width: 200 },
                    { field: 'BatchNO', title: '物料批号', width: 150 },
                    { field: 'ReciveQty', title: '收料数量', width: 80 },
                    { field: 'MaterialName', title: '物料名称', width: 250 },
                    { field: 'MaterialDesc', title: '物料规格', width: 250 }



                ]],
                loadFilter: function (data) {
                    return JSON.parse(data);
                },
                toolbar: "#toolbar",
                rownumbers: true,   //行号 
                onLoadSuccess: function (data) {
                    $('#OrderItem').datagrid("fillRows");
                    $('#OrderItem').datagrid('resize');
                },
                onDblClickRow: function (index, row) {
                    if (row == null) {
                        Alert("Please Select One Row");
                        return false;
                    }
                    $('#hReciveItemID').val(row.ReciveItemID);
                    $('#txtMaterialNO').val(row.MaterialNO);
                    $('#txtMaterialName').val(row.MaterialName);
                    $('#txtBatchNO').val(row.BatchNO);
                    $('#txtReciveQty').val(row.ReciveQty);
                    $('#txtErpItem').val(row.ERPItem);
                    $('#hReciveOrderNO').val(row.ReciveOrderNO);
                    $('#txtReciveQty').textbox('setValue', row.ReciveQty);
                    $('#txtMaterialNO').textbox('setValue', row.MaterialNO);
                    $('#txtMaterialName').textbox('setValue', row.MaterialName);
                    $('#txtBatchNO').textbox('setValue', row.BatchNO);
                    $('#txtErpItem').textbox('setValue', row.ERPItem);
                    SelectRow(row.ReciveItemID);
                    

                },
                onSortColumn: function (sort, order) {
                    $("#hSort").val(order);
                    $("#hOrder").val(sort);
                }
            });
        }
        function SelectRow(ReciveItemID) {
            ReciveOrderNO = $('#hReciveOrderNO').val();

            $("#BarCode").datagrid({
                url: '/api/BAS/GetBarcodeByReceiveOrder',
                method: 'Get',
                queryParams: {
                    ReciveItemID: ReciveItemID,
                    ReciveOrderNO: ReciveOrderNO,
                    order: '',
                    sort: ''
                },
                height: document.documentElement.clientHeight - 390,
                pageSize: 20,
                columns: [[
                    { field: 'BarcodeID', title: '条码ID', checkbox: true },
                    { field: 'BarcodeNO', title: '物料条码', width: 200 },
                    { field: 'Qty', title: '包装数量', width: 80 },
                    { field: 'MaterialNO', title: '物料编号', width: 200 },
                    { field: 'BatchNO', title: '批号', width: 120 },
                    { field: 'ReciveOrderNO', title: '收料单号', width: 150 },
                    { field: 'ERPItem', title: '收料项次', width: 80 }
                ]],
                onLoadSuccess: function (data) {
                    $('#BarCode').datagrid("fillRows");
                    $('#BarCode').datagrid('resize');
                },
                loadFilter: function (data) {
                    if (data.d) {
                        return data.d;
                    } else {
                        return JSON.parse(data);
                    }

                }
            });
           
          
        }

        function Update()
        {
            var ReciveItemID = $('#hReciveItemID').val();
            var ReciveQty = $('#txtReciveQty').val();
            var BatchNO = $('#txtBatchNO').val();
            var Info = {
                ReciveItemID: ReciveItemID,
                ReciveQty: ReciveQty,
                BatchNO: BatchNO
            }
            var url = "/api/WMS/ResetReceiveOrderItem";
            DataService.AjaxPost(url, Info, function (data) {
               
                Notice(data.Message);
                $('#txtReciveQty').textbox('setValue', "");
                $('#txtMaterialNO').textbox('setValue',"");
                $('#txtMaterialName').textbox('setValue',"");
                $('#txtBatchNO').textbox('setValue',"");
                $('#txtErpItem').textbox('setValue', "");
                $('#hReciveItemID').val("");
                $('#OrderItem').datagrid('unselectAll');
                $('#BarCode').datagrid('reload');
                $('#OrderItem').datagrid('reload');
                
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:HiddenField ID="hReceiveOrderID" runat="server" />
        <asp:HiddenField ID="hReciveItemID" runat="server" />
        <asp:HiddenField ID="hReciveOrderNO" runat="server" />
        <asp:HiddenField runat="server" ID="hSort" />
        <asp:HiddenField runat="server" ID="hOrder" />
        <div>
                <div class="easyui-layout" style="width: 100%; height: 530px">
                    <%--左侧视图--%>
                    <div id="p" data-options="region:'west'" title="Order Item List" style="width: 60%;">
                        <div class="pagebox">
                            <div class="cbox">
                                <!--查询结果清单-->
                                <table id="OrderItem"  title="Order Item List" data-options="
                                                  rownumbers:true,
                                                  singleSelect:true,
                                                  pagination: true,
                                                  autoRowHeight:false,
                                                  fitColumns:true,
                                                  pageSize:20">
                                 
                                </table>
                            </div>
                        </div>
                    </div>

                    <%--右侧视图--%>
                    <div data-options="region:'center'" title="Receive Item Information">
                        <div class="pagebox">
                            <div class="cbox">
                                <!--工具栏-->
                                <div class="easyui-panel" style="padding: 15px; width: 100%;">
                                    <div id="tb">
                                        <ul class="flist">
                                                             <li>
                     <input class="easyui-textbox" type="text" readonly="true"  id="txtErpItem" data-options="label:'ERP Item:'" style="width: 350px; height: 35px; line-height: 35px;" />
                          </li>
                                         <li>
                                             <input class="easyui-textbox" type="text" readonly="true"  id="txtMaterialNO" data-options="label:'Part NO:'" style="width: 350px; height: 35px; line-height: 35px;" />
                                                  </li>
         <li>    
                                             <input class="easyui-textbox" type="text" id="txtBatchNO"  data-options="label:'Lot NO:'" style="width: 350px; height: 35px; line-height: 35px;" />
                                         </li>
                                             <li>
     <input class="easyui-textbox" type="text" id="txtReciveQty"  data-options="label:'Recive Qty:'" style="width: 350px;  height: 35px; line-height: 35px;" />
                                                       </li>
          <li>
     <input class="easyui-textbox" type="text" id="txtMaterialName"  readonly="true"   data-options="label:'Part Name:'"  style="width: 350px; height: 35px; line-height: 35px;" />
 </li>
                                        </ul>
                                        <div>
                                            <a href="#" class="easyui-linkbutton c1" onclick="Update()" data-options="iconCls:'icon-sousuo',selected:true">Save</a>
                                           
                                        </div>

                                    </div>
                                </div>
                            </div>
                            <div class="cbox">
                                <!--查询结果清单-->
                                <table id="BarCode"  title="Barcode List" data-options="
                                                  rownumbers:true,
                                                  pagination: true,
                                                  autoRowHeight:false,
                                                  fitColumns:true,
                                                  pageSize:20" style="width:100%">
                               

                                </table>

                            </div>
                        </div>
                    </div>
                </div>
        </div>
    </form>
</body>
</html>
